<template>
  <div id="app">
    <!-- Head Area -->
    <Header></Header>
    <!-- 动态加载ALList/DoneList/TodoList -->
    <transition enter-active-class="animate__animated animate__fadeInDown">
      <keep-alive>
        <component :is="comName"></component>
      </keep-alive>
    </transition>
    <!-- Tab 切换 -->
    <div class="tab-contanier">
      <div class="btns">
        <button ref="tabTodoRef" class="tab-todo active" @click="to_todoList">待办项</button>
        <button ref="tabAllRef" class="tab-All" @click="to_AllList">全部</button>
        <button ref="tabDoneRef" class="tab-done" @click="to_doneList">已完成</button>
      </div>
    </div>
    <!-- Footer Area -->
    <Footer></Footer>
  </div>
</template>

<script>
// import Count from '@/components/Count/Count.vue'
// import ListItem from '@/components/ListItem/ListItem.vue'
import Header from '@/components/Header/Header.vue'
import DoneList from '@/components/DoneList/DoneList.vue'
import TodoList from '@/components/TodoList/TodoList.vue'
import AllList from '@/components/AllList/AllList.vue'
import Footer from '@/components/Footer/Footer.vue'

// import { mapGetters, mapState } from 'vuex'
export default {
  name: 'App',
  components: { Header, DoneList, TodoList, AllList, Footer },
  data() {
    return {
      comName: 'TodoList',
      show: true
    }
  },
  methods: {
    to_todoList() {
      this.comName = 'TodoList'
      this.$refs.tabDoneRef.classList.remove('active')
      this.$refs.tabAllRef.classList.remove('active')
      this.$refs.tabTodoRef.classList.add('active')
    },
    to_AllList() {
      this.comName = 'AllList'
      this.$refs.tabTodoRef.classList.remove('active')
      this.$refs.tabDoneRef.classList.remove('active')
      this.$refs.tabAllRef.classList.add('active')
    },
    to_doneList() {
      this.comName = 'DoneList'
      this.$refs.tabTodoRef.classList.remove('active')
      this.$refs.tabAllRef.classList.remove('active')
      this.$refs.tabDoneRef.classList.add('active')
    }
  }
}
</script>

<style lang="less">
#app {
  padding-bottom: 50px;
}
.btns {
  display: flex;
  flex-direction: row;
  width: 250px;
  height: 25px;
  border-radius: 20px;
  margin: 0 auto;
  .tab-todo {
    flex: 1;
    border-radius: 20px 0 0 20px;
    border-right: 1px solid #ccc;
  }
  .tab-All {
    flex: 1;
  }
  .tab-done {
    flex: 1;
    border-radius: 0 20px 20px 0;
    border-left: 1px solid #ccc;
  }
}

@media screen and (min-width: 900px) {
  .tab-contanier {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    left: 15%;
  }
  .btns {
    flex-direction: column;
    width: 25px;
    height: 250px;
    .tab-todo {
      border-radius: 20px 20px 0 0;
      border-bottom: 1px solid #ccc;
    }
    .tab-done {
      border-radius: 0 0 20px 20px;
      border-top: 1px solid #ccc;
    }
  }
}
.active {
  background-color: #629a9c;
}
</style>
